local zhengnan = fk.CreateSkill {
  name = "mini__zhengnan",
}

Fk:loadTranslationTable{
  ["mini__zhengnan"] = "征南",
  [":mini__zhengnan"] = "每名角色限一次，当一名角色进入濒死状态时，你可以摸三张牌并选择获得下列技能中的一个："..
  "〖武圣〗〖当先〗〖制蛮〗。",

  ["$mini__zhengnan"] = "南蛮未定，怎可独以家为？",
}

zhengnan:addEffect(fk.EnterDying, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(zhengnan.name) and not table.contains(player:getTableMark(zhengnan.name), target.id)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:addTableMark(player, zhengnan.name, target.id)
    player:drawCards(3, zhengnan.name)
    if player.dead then return end
    local choices = { "ex__wusheng", "m_ex__dangxian", "ty_ex__zhiman" }
    for i = 3, 1, -1 do
      if player:hasSkill(choices[i], true) then
        table.removeOne(choices, choices[i])
      end
    end
    if #choices > 0 then
      local choice = room:askToChoice(player, {
        choices = choices,
        skill_name = zhengnan.name,
        prompt = "#zhengnan-choice",
        detailed = true,
      })
      room:handleAddLoseSkills(player, choice)
    end
  end,
})

return zhengnan
